package top.lshaci.learning.jvm.ref;

import java.util.concurrent.TimeUnit;

/**
 * StrongReferenceTest
 *
 * @author lshaci
 * @date 2020/8/7 16:36
 * @since 1.0.0
 */
public class StrongReferenceTest {

    public static void main(String[] args) throws Exception {
        StringBuilder str = new StringBuilder("213");
        StringBuilder str1 = str;

        str = null;
        System.gc();
        /**
         * 虽然str指向了空
         * 但是str1仍然指向堆中的对象，所以不会被回收
         * 除非str 和 str1 都断开引用
         */
        TimeUnit.SECONDS.sleep(3);
    }
}
